<template>
	<view>
		<view class="news-list">
 			<view class="news-item" v-for="item in newList" :key="item.id" @click="toDetail(item.id)">
				<view class="item-left">
					<image class="news-imgage" :src="getImageUrl(item.img)"></image>
				</view>
				<view class="item-right">
					<view class="news-title">{{item.title}}</view>
					<view class="news-date">{{item.atime}}</view>
					<!-- <view class="news-type">{{item.type==0? "权益":"新闻"}}</view> -->
				</view>
			</view> 
		</view>
	</view>
</template>

<script>
	
	import { getToken, getNewsList, getImageUrl} from '@/api/home'
	
	export default {
		data() {
			return {
				param:{},
				newList:[]
			}
		},
		onLoad(){
			this.getNews();
		},
		methods: {
			getNews(){
				this.param.token = uni.getStorageSync("token");
				getNewsList(this.param).then(res => {
					this.newList = res.newsList
				})
			},
			toDetail(id){
				console.log('新闻明细：',id)
				uni.navigateTo({
					url:"/pages/index/news/detail?id=" + id
				})
			},
			getImageUrl(src){
				return this.domain + src;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.news-list {
		padding: 0 15rpx;
		flex-wrap: wrap;
		justify-content: space-between;
		.news-item {
			display: flex;
			background-color: #f5f5f5;
			height: 170rpx;
			width: 100%;
			margin: 5rpx 0;
			padding: 10rpx;
			.item-left {
				width: 38%;
				.news-imgage {
					width: 100%;
					height: 150rpx;
					border-radius: 8rpx;
				}
			};
			.item-right {
				width: 55%;
				margin: 10rpx 20rpx;
				.news-title {
					// text-overflow: ellipsis;
					// overflow: hidden;
					// white-space: nowrap;
					// justify-content: center;
					
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					font-size: 30rpx;
					height: 80rpx;
				};
				.news-date {
					margin: 5rpx 0;
					color: #999999;
					margin-top: 15rpx;
				}
			}
			// .news-type {
			// 	background-color: #007AFF;
			// 	width: 80rpx;
			// 	height: 50rpx;
			// 	padding: 3rpx 10rpx;
			// 	color: #FFFFFF;
			// 	margin-left: -360rpx;
			// 	margin-top: 10rpx;
			// 	border-radius: 8rpx;
			// };
		}
	}
</style>
